﻿create PROCEDURE Sync.SP_CommittessVillages_SelectChanges
@LastRowVersion rowversion,
@FilterdColumn UNIQUEIDENTIFIER
AS 
BEGIN 
	SELECT 
        t.[CommitteID],t.[VillageID],
		
		t.IsDeleted,
		t.LastUpdatedDate
	FROM [dbo].[CommittessVillages] g RIGHT JOIN Sync.CommittessVillages_Tracking t  
    ON t.CommitteID = g.CommitteID AND t.VillageID = g.VillageID 
	WHERE (@LastRowVersion IS NULL OR t.Version > @LastRowVersion)
	AND ((@FilterdColumn IS NULL) OR (g.[CommitteID] = @FilterdColumn))
    END











